<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>CSS Grids</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>CSS Grids</h1>

    
        <a href="#toc" class="jump">Jump to Table of Contents</a>
    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content">				<div class="intro">
                	
					<p>The foundational CSS Grids provides a simple system for layout out content.  The basic components are "grids" and "units".  A "grid" (<code>yui3-g</code>) contains one or more "units" (<code>yui3-u</code>).  The type of "unit" chosen describes how it should be sized (e.g. "yui3-u-1-2" takes up half the grid, "yui3-u-1-3" takes up one-third, et cetera). The only constrains for YUI3 Grids are that all "units" are children of a "grid". All you need to do is define a grid, one or more units inside it, and specify widths for them. Then stack and nest as required.</p>
                </div>

					<h2 id="start">Getting Started</h2>

					<h3 id="dependencies">Include Dependencies</h3>

					<p>To use CSS Grids, include the following source file in your web page with the link element.</p>

<pre class="code prettyprint">&lt;link rel=&quot;stylesheet&quot; type=&quot;text&#x2F;css&quot; href=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.4.1&#x2F;build&#x2F;cssgrids&#x2F;grids-min.css&quot;&gt;</pre>


						<h2 id="using">Using YUI CSS Grids</h2>

                        <h3 id="unit-sizes">Unit Sizes</h3>
                        <p>All of the sizing for YUI Grids is done using "units".  Units can be subdivided up to 1/24 of the available width.  The following table gives the various unit classes that can be applied.</p>
                        <table class="auto">
                            <thead>
                                <tr>
                                    <th>Class</th>
                                    <th>Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><code>.yui3-u</code></td>
                                    <td>Shrinks to fit unless a width is applied.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1</code></td>
                                    <td>Fills 100% of the available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-2</code></td>
                                    <td>Fills 1/2 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-3</code></td>
                                    <td>Fills 1/3 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-2-3</code></td>
                                    <td>Fills 2/3 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-4</code></td>
                                    <td>Fills 1/4 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-3-4</code></td>
                                    <td>Fills 3/4 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-5</code></td>
                                    <td>Fills 1/5 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-2-5</code></td>
                                    <td>Fills 2/5 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-3-5</code></td>
                                    <td>Fills 3/5 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-4-5</code></td>
                                    <td>Fills 4/5 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-6</code></td>
                                    <td>Fills 1/6 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-5-6</code></td>
                                    <td>Fills 5/6 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-8</code></td>
                                    <td>Fills 1/8 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-3-8</code></td>
                                    <td>Fills 3/8 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-5-8</code></td>
                                    <td>Fills 5/8 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-7-8</code></td>
                                    <td>Fills 7/8 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-12</code></td>
                                    <td>Fills 1/12 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-5-12</code></td>
                                    <td>Fills 5/12 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-7-12</code></td>
                                    <td>Fills 7/12 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-11-12</code></td>
                                    <td>Fills 11/12 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-1-24</code></td>
                                    <td>Fills 1/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-5-24</code></td>
                                    <td>Fills 5/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-7-24</code></td>
                                    <td>Fills 7/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-11-24</code></td>
                                    <td>Fills 11/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-13-24</code></td>
                                    <td>Fills 13/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-17-24</code></td>
                                    <td>Fills 17/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-19-24</code></td>
                                    <td>Fills 19/24 of available width.</td>
                                </tr>
                                <tr>
                                    <td><code>.yui3-u-23-24</code></td>
                                    <td>Fills 23/24 of available width.</td>
                                </tr>
                            </tbody>
                        </table>	
                        
                <h3 id="page_width">Building a Page Template</h3>
                    
                <p>The sizing of "units" is done using percentages, so in order to build a "page" template, a width on the outermost container is required.  The simplest approach to fixing your page size is to apply a width directly to the body element.  Optionally, the page can be centered in the viewport by  setting the <code>margin</code> to <code>auto</code>.  The following creates a 960px, centered layout.</p>

<pre class="code prettyprint">body {
    margin: auto; &#x2F;* center in viewport *&#x2F;
    width: 960px;
}</pre>


            <p>The next step is to decide on the size of each "column" and choose the appropriate "unit".  Remember, units sizes are percentage-based, so a bit of math may be required when designing with pixels rather than proportions.  To create a 200 pixel wide sidebar, assuming a 960px layout, we would use a 5/24 unit ("yui3-u-5-24") for the narrow column, and a 19/24 ("yui3-19-24") for the main column.</p>

<pre class="code prettyprint">&lt;head&gt;
    &lt;style&gt;
    body {
        margin: auto; &#x2F;* center in viewport *&#x2F;
        width: 960px;
    }

    &lt;&#x2F;style&gt;
&lt;&#x2F;head&gt;

&lt;body&gt;
    &lt;div class=&quot;yui3-g&quot;&gt;
        &lt;div class=&quot;yui3-u-5-24&quot;&gt;

        &lt;&#x2F;div&gt;
        &lt;div class=&quot;yui3-u-19-24&quot;&gt;

        &lt;&#x2F;div&gt;
    &lt;&#x2F;div&gt;
&lt;&#x2F;body&gt;</pre>

        <h3 id="pixels">Pixel Units</h3>
        <p>Some layouts have precise sizing requirements that may not always be fulfilled by percentage-based units.  Custom unit sizes may be applied using the generic unit ("yui3-u").  Rather than overriding the YUI units, custom sizing should be done using your own semantic markup.  To recreate the previous example with custom units, we will add IDs to the column containers.  This examples uses "nav" and "main", but these should be tailored to your content.</p>

<pre class="code prettyprint">&lt;head&gt;
    &lt;style&gt;
    body {
        margin: auto; &#x2F;* center in viewport *&#x2F;
        width: 960px;
    }

    #nav {
        width: 200px;
    }

    #main {
        width: 760px;
    }

    &lt;&#x2F;style&gt;
&lt;&#x2F;head&gt;

&lt;body&gt;
    &lt;div class=&quot;yui3-g&quot;&gt;
        &lt;div class=&quot;yui3-u&quot; id=&quot;nav&quot;&gt;

        &lt;&#x2F;div&gt;
        &lt;div class=&quot;yui3-u&quot; id=&quot;main&quot;&gt;

        &lt;&#x2F;div&gt;
    &lt;&#x2F;div&gt;
&lt;&#x2F;body&gt;</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            
                <div id="toc" class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Table of Contents</h2>
                    </div>

                    <div class="bd">
                        <ul class="toc">
<li>
<a href="#start">Getting Started</a>
<ul class="toc">
<li>
<a href="#dependencies">Include Dependencies</a>
</li>
</ul>
</li>
<li>
<a href="#using">Using YUI CSS Grids</a>
<ul class="toc">
<li>
<a href="#unit-sizes">Unit Sizes</a>
</li>
<li>
<a href="#page_width">Building a Page Template</a>
</li>
<li>
<a href="#pixels">Pixel Units</a>
</li>
</ul>
</li>
</ul>
                    </div>
                </div>
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Each unit has a className that provides its percentage width.">
                                        <a href="cssgrids-units.html">Using Grid Units</a>
                                    </li>
                                
                            
                                
                                    <li data-description="This is a template for creating fixed-width layouts.">
                                        <a href="cssgrids-fixed.html">Fixed Page Template</a>
                                    </li>
                                
                            
                                
                                    <li data-description="This is a template for creating fluid layouts.">
                                        <a href="cssgrids-fluid.html">Fluid Page Template</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Basic CSS properties are leveraged to horizontally and vertically align units.">
                                        <a href="cssgrids-align.html">Aligning Grid Units</a>
                                    </li>
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                        </ul>
                    </div>
                </div>
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples That Use This Component</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                                    <li data-description="Creating left navigation using the MenuNav Node Plugin.">
                                        <a href="../node-menunav/menunav-leftnav.html">Basic Left Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating top navigation using the MenuNav Node Plugin">
                                        <a href="../node-menunav/node-menunav-2.html">Basic Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating menu button navigation using the MenuNav Node Plugin">
                                        <a href="../node-menunav/node-menunav-3.html">Menu Button Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating split button navigation using the MenuNav Node Plugin">
                                        <a href="../node-menunav/node-menunav-4.html">Split Button Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Adding shadows to submenus of a left nav using the MenuNav Node Plugin">
                                        <a href="../node-menunav/node-menunav-5.html">Left Nav with Submenus with Shadows</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Adding rounded corners to submenus of a left nav using the MenuNav Node Plugin">
                                        <a href="../node-menunav/node-menunav-6.html">Left Nav With Submenus With Rounded Corners</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Skining a menu built using the MenuNav Node Plugin to look like the menus on Flickr">
                                        <a href="../node-menunav/node-menunav-7.html">Skinning Menus Created Using the MenuNav Node Plugin</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
